<template>
	<view class="container">
		
		<view class="student-bg">
			<image src="../../static/img/bg2.png"></image>
		</view>
		
		<view class="title">门禁历史</view>
		
		<block v-for="(mClass,index) in classList" :key="mClass.Id">
			<view class="title-box">
				<view class="class-title-box">
					<view class="class-title">班级成员</view>
					<view class="class-num">（共{{mClass.StudentNum}}人）</view>
					<view class="class-name">{{mClass.Name}}</view>
				</view>
			</view>
			<view class="class-students">
				<view @tap="jump(student.Id,student.RealName)" class="student-box" v-for="(student,index) in mClass.StudentList" :key="student.Id">
					<view class="head-img-box">
						<image class="head-img" src="../../static/img/2.png"></image>
					</view>
					<view class="name">{{student.RealName}}</view>
				</view>
			</view>
		</block>
		
	</view>
</template>

<script>
	import {myRequest} from '../../utils'
	
	export default {
		data() {
			return {
				loading: false,
				classList: [],
				timer: null
			}
		},
		
		onShow() {
			
			let that = this
			if (that.loading) return
			that.loading = true
			
			uni.showLoading({
				title: '拼命加载中...',
				success() {
					
					if (that.timer != null) {
						clearTimeout(that.timer)
					}
					
					that.timer = setTimeout(function() {
						
						myRequest({
							url: '/api/access_control/class_students',
							data: {},
						}, function(res) {
							
							that.loading = false
							uni.hideLoading()
							
							if (res.statusCode != 200) {
								uni.showModal({
									title: '提示',
									content: '服务器错误，请求失败'
								})
								return
							}
							
							if (res.data.status != 0) {
								uni.navigateTo({
									url: '/pages/login/login'
								})
								return
							}
							
							that.classList = res.data.data
							
						})
						
					}, 1000)
					
				}
			})
			
		},
		
		methods: {
			jump(id, name) {
				uni.navigateTo({
					url: '/pages/teacher_access_control_list/teacher_access_control_list?id=' + id + '&name=' + name
				})
			}
		}
	}
</script>

<style>
	.student-bg {
		position: absolute;
		width: 400rpx;
		height: auto;
		right: 0;
		top: 0;
		z-index: 100;
	}
	
	.container {
		width: 750rpx;
		height: auto;
		background-image: linear-gradient(#ffae00, #eee, #efefef);
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: 160rpx;
		min-height: 1800rpx;
	}
	
	.title-box {
		width: 750rpx;
		margin-left: 120rpx;
	}
	
	.title {
		width: 100%;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		font-size: 50rpx;
		margin-left: 120rpx;
	}
	
	.class-title-box {
		width: 100%;
		height: 60rpx;
		display: flex;
		margin-top: 60rpx;
		z-index: 101;
	}
	
	.class-title {
		font-size: 46rpx;
	}
	
	.class-num {
		font-size: 32rpx;
		margin-top: 22rpx;
	}
	
	.class-name {
		position: absolute;
		right: 0;
		height: 56rpx;
		line-height: 56rpx;
		background-color: #ffffff;
		font-size: 36rpx;
		box-shadow: 6rpx 4rpx 18rpx 0rpx rgba(145, 124, 24, 0.4);
		border-top-left-radius: 26rpx;
		border-bottom-left-radius: 26rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}
	
	.class-students {
		display: flex;
		flex-wrap: wrap;
		z-index: 102;
		width: 700rpx;
		margin-top: 10rpx;
	}
	
	.student-box {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 30rpx;
		width: 140rpx;
	}
	
	.head-img-box {
		position: relative;
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
		background-color: #ffffff;
		overflow: hidden;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.head-img {
		position: absolute;
		width: 70rpx;
		height: 70rpx;
	}
	
	.head-img-gray {
		position: absolute;
		width: 70rpx;
		height: 70rpx;
	}
	
	.head-img-gray::after {
		content: '';
		position: absolute;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		background-color: rgba(255, 255, 255, 0.5);
	}
	
	.name {
		font-size: 30rpx;
		margin-top: 6rpx;
	}
</style>
